package com.String;

/*
查找以.txt结尾的文件
*/
public class Demo08 {
    public static void main(String[] args) {
        String[] filesPath = {"d:/a.png", "c:/aaa/a.txt", "d:/aaa/bbb/e.txt",
                "c:/c/aa/b.txt", "c:/aaa/g.txt", "c:/aaa/c.png",
                "d:/aaa/d.jpg", "d:/ccc/ddd/eee/g.mp3", "d:/nnn/mmm/kkkk/m.txt"};
        int count = 0;
        //遍历字符串数组
        for (int i = 0; i < filesPath.length; i++) {
            boolean endsWith = filesPath[i].endsWith(".txt");
            if (endsWith) {
                count++;
                String[] file = filesPath[i].split("/");
                System.out.println(file[file.length - 1]);
            }
        }
        if (count != 0) {
            System.out.println("有" + count + "个");
        } else {
            System.out.println("不存在！");
        }
    }

}
